import java.util.HashMap;
import java.util.Map;

public class test {

    public int removeStones(int[][] stones) {
        UnionFind unionFind = new UnionFind();

        for (int[] stone : stones){
            unionFind.union(stone[0]+1001,stone[1]);
        }
        return stones.length-unionFind.count;
    }

    private class UnionFind{
        private Map<Integer,Integer> parents;
        private int count;


        public UnionFind() {
            this.parents = new HashMap<>();
            this.count = 0;
        }

        public int getCount() {
            return count;
        }

        public int find(int x){
            if (!parents.containsKey(x)){
                parents.put(x,x);
            }


            return 0;
        }

        public void union(int i, int i1){

        }


    }
}

